package home.control.logicElements;

import java.util.Date;

public class Action implements Comparable<Action> {
	private HomeParts partOfHome;
	private ActionTypes action;
	private Date time;
	
	public Action(HomeParts allHouse, ActionTypes action, Date time) {
		this.partOfHome = allHouse;
		this.action = action;
		this.time = time;
	}
	
	public Date getDate(){
		return time;
	}

	@Override
	public String toString(){
		return partOfHome + " | " + action + " | " + String.format("%02d", time.getHours())+":"+String.format("%02d", time.getMinutes());
	}

	@Override
	public int compareTo(Action another) {
		int timeRel = time.getHours()*100 + time.getMinutes();
		int timeRelComp = another.getDate().getHours()*100 + another.getDate().getMinutes();
		if(timeRel < timeRelComp){
			return -1;
		}else if(timeRel > timeRelComp){
			return 1;
		}else{
			return 0;
		}
	}
	
	public HomeParts getPartOfHome() {
		return partOfHome;
	}

	public void setPartOfHome(HomeParts partOfHome) {
		this.partOfHome = partOfHome;
	}

	public ActionTypes getAction() {
		return action;
	}

	public void setAction(ActionTypes action) {
		this.action = action;
	}

	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}
}
